#!/usr/bin/env python
#ecoding = utf-8
__author__ = 'lihao'
import pandas as pd
from pandas import DataFrame
from pylab import *
import matplotlib.pyplot as plot
target_url = ("https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data")
abalone = pd.read_csv(target_url, header=None, prefix="V")
abalone.columns = ['Sex', 'Length', 'Diameter', 'Height', 'Whole weight', 'Shucked weight', 'Viscera weight','Shell weight', 'Rings']

print(abalone.head())
print(abalone.tail())

summary = abalone.describe()
print(summary)

fig = plot.figure()
ax1 = fig.add_subplot(111)
ax1.set_title('Scatter Plot')
array = abalone.ix[:, 1:9].values
boxplot(array)
plot.xlabel("Attribute Index")
plot.ylabel("Quartiles Ranges")
show()

fig = plot.figure()
ax1 = fig.add_subplot(111)
ax1.set_title('Scatter Plot1234565')
array2 = abalone.ix[:, 1:8].values
boxplot(array2)
plot.xlabel("Attribute Index")
plot.ylabel("Quartiles Ranges")
show()


abaloneNormalized = abalone.ix[:, 1:9]
for i in range(8):
    mean = summary.ix[1, i]
    sd = summary.ix[2, i]
abaloneNormalized.ix[:, i:(i+1)] = (abaloneNormalized.ix[:, i:(i+1)] - mean) / sd

array3 = abaloneNormalized.values
boxplot(array3)
plot.xlabel("Attribute Index")
plot.ylabel("Quartile Ranges - Normalized")
show()
